package com.weixin.engine.controller;

import com.weixin.common.core.doman.Result;
import com.weixin.engine.daily.distribute.Handler;
import com.weixin.engine.daily.distribute.HandlerDispatch;
import com.weixin.engine.daily.distribute.Employee;
import com.weixin.engine.daily.variable.BService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author wangchunhui
 * @date 2022/10/24 10:57
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private HandlerDispatch handlerDispatch;

    @Resource
    private BService bService;

    @PostMapping("/handler")
    public Result findAll(Employee employee) {
        Handler<Employee, Result> handler = handlerDispatch.getHandle("BHandle");
        Object o = handler.handle(employee);
        return (Result) o;
    }

    @GetMapping("/handler1")
    public Result findAll() {
        bService.method();
        return Result.SUCCESS();
    }
}
